<!--
 * @Description: 依赖注入
 * @Author: Zhanghan
 * @Date: 2025-01-18 17:42:39
 * @LastEditTime: 2025-01-18 18:06:55
 * @LastEditors: Zhanghan
-->
<template>
  <div class="myprovide" >
    <h1 class="mb-12" >依赖注入</h1>
    <ElButton type="primary" @click="updateCount" >点击更新数字</ElButton>
    <ChildOne  />
  </div>
</template>

<script lang="ts" setup>
import { ref, provide } from "vue";
import { ElButton } from 'element-plus';
import ChildOne from "./components/ChildOne.vue";

const count = ref(0);

// 给定依赖
provide("count", count);

const updateCount = () => {
  count.value++;
};
</script>

<style scoped lang="less">
.myprovide{
    width: 100%;
    height: 100%;
}
</style>
